<?php
/**
 * indexAction 
 * 
 * 首页，获取默认分类数据.
 *
 */
class indexAction{
	
	public function action($_get){  
		require_once "Action/common.php";

		//获取分页信息

		$page_num = 1;
		if($_get['page']){
			if($_get['page']>100){
				$page_num = 93;
			}
			else{
				$page_num = $_get['page'];
			}
		}

		$cid = CID;
		if($_get['cid']){
			$cid = $_get['cid'];
			$cid = getNoiseCid($cid);
		}


		$keyword = '';
		if($_get['keyword']){$cid = $_get['keyword'];}
		

		//查询淘宝客推广商品(taobao.taobaoke.items.get)

		$Taoapi->method = 'taobao.taobaoke.items.get';

		$Taoapi->fields = 'num_iid,iid,title,nick,pic_url,price,click_url,commission,commission_rate,commission_num,commission_volume,seller_credit_score,item_location,shop_click_url';

		$Taoapi->nick = USERNICK;				//推广者昵称
		$Taoapi->cid = $cid;
		if($keyword){							//废弃
			$Taoapi->keyword = urldecode($keyword);
		}
		$Taoapi->page_no   = $page_num;
		$Taoapi->page_size = PAGE_SIZE;
		
		
		$Taoapi->start_credit = STARTCREDIT;	//商家开始信用
		
		$Taoapi->end_credit = ENDCREDIT;		//商家结束信用
		
		$Taoapi->sort = SORTBY;					//推广商品排序

		//需要更多的字段可以登陆 taoapi.com 进行配置生成
		$TaobaokeData = $Taoapi->Send('get','xml')->getArrayData();
		
		$show_array=array();
		$show_array= $TaobaokeData['taobaoke_items']['taobaoke_item'];
		

		$page_size		= PAGE_SIZE;
		$pageCurrent	= $page_num;
		$sub_pages		= PAGE_ACTIVE;
		$nums			= ($TaobaokeData['total_results']>2000)?2000:$TaobaokeData['total_results'];
		

		
		//分页
		$subPages = new SubPages($page_size,$nums,$pageCurrent,$sub_pages,SITEPATH."index.php/index/page/",2);
		$pages    = $subPages->subPageCss2();

		//分配变量

		$tpl->assign("nobaiduContent",$article);

		$tpl->assign("mm_index_key",KEYW);			//关键字
		$tpl->assign("mm_index_des",DES.date("Y-m-d H:i:s"));			//描述
		$tpl->assign("mm_beian",ICPBEIAN);			//备案号
		$tpl->assign("mm_pages",$pages);			//分页
		$tpl->assign("item",$show_array);			//内容
		$tpl->assign("siteflag",FLAG);				//站点标记
		$tpl->assign("nobaidu",$nobaidu);			//不是百度?

		$tpl->assign("mm_webname",SITETITLE);		//站点标题
		$tpl->display("mm_index.html","index");		

	}
}
?>